#include <stdio.h>	
#include <sys/types.h>	       /* See NOTES */
#include <sys/socket.h>
#include <string.h>
#include <sys/ioctl.h>
//#include <netinet/in.h>
#include "wireless.h"

int main(int argc, char const* argv[])
{
	struct iwreq wrq;
	char essid[IW_ESSID_MAX_SIZE+2] = {0};
	int sockfd = -1;

	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
	memset(&wrq, 0, sizeof(wrq));

	wrq.u.essid.pointer = (caddr_t)essid;
	wrq.u.essid.length = IW_ESSID_MAX_SIZE + 2;
	wrq.u.essid.flags = 0;

	strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ);
	ioctl(sockfd, SIOCGIWESSID, &wrq);

	printf("essid: %s\n", essid);

	return 0;
}
